package ssau.knyazev.wavelet.core;

import ssau.knyazev.common.UniException;
import ssau.knyazev.core.image.ImageModel;

public class WaveletScript {

	protected static boolean executed = false;
	
	public static void runScript() throws UniException{
		executed = false;
		ImageModel im = new ImageModel("image.bmp");
		im.applyContrast();
		
		ImageModel csum1 = WaveletCore.colSumCMP(im);
		ImageModel rsum1 = WaveletCore.rowSumCMP(csum1);
		ImageModel csum2 = WaveletCore.colSumCMP(rsum1);
		ImageModel rsum2 = WaveletCore.rowSumCMP(csum2);
		
		ImageModel cdif1 = WaveletCore.colDifferenceCMP(im);
		ImageModel rdif1 = WaveletCore.rowDifferenceCMP(cdif1);
		ImageModel cdif2 = WaveletCore.colDifferenceCMP(rdif1);
		ImageModel rdif2 = WaveletCore.rowDifferenceCMP(cdif2);
		
		cdif1 = WaveletCore.filtration(cdif1, 2);
		cdif2 = WaveletCore.filtration(cdif2, 2);
		rdif1 = WaveletCore.filtration(rdif1, 2);
		rdif2 = WaveletCore.filtration(rdif2, 2);
		
		ImageModel csoi2 = WaveletCore.colSumRCV(rdif2, rsum2);
		ImageModel rsoi1 = WaveletCore.rowSumRCV(cdif2, csoi2);
		ImageModel csui1 = WaveletCore.colSumRCV(rdif1, rsoi1);
		ImageModel oi = WaveletCore.rowSumRCV(cdif1, csui1);
		
		ImageModel.writeImage(csum1, ".//images//01ColumnSumCompression1.bmp");
		ImageModel.writeImage(rsum1, ".//images//02ColumnRowSumCompression1.bmp");
		ImageModel.writeImage(csum2, ".//images//03ColumnSumCompression2.bmp");
		ImageModel.writeImage(rsum2, ".//images//04ColumnRowSumCompression2.bmp");
		ImageModel.writeImage(cdif1, ".//images//05ColumnDifCompression1.bmp");
		ImageModel.writeImage(rdif1, ".//images//06ColumnRowDifCompression1.bmp");
		ImageModel.writeImage(cdif2, ".//images//07ColumnDifCompression2.bmp");
		ImageModel.writeImage(rdif2, ".//images//08ColumnRowDifCompression2.bmp");
		ImageModel.writeImage(cdif1, ".//images//09ColumnDifCompression1F.bmp");
		ImageModel.writeImage(rdif1, ".//images//10ColumnRowDifCompression1F.bmp");
		ImageModel.writeImage(cdif2, ".//images//11ColumnDifCompression2F.bmp");
		ImageModel.writeImage(rdif2, ".//images//12ColumnRowDifCompression2F.bmp");
		ImageModel.writeImage(csoi2, ".//images//13ColRCV1.bmp");
		ImageModel.writeImage(rsoi1, ".//images//14ColRowRCV1.bmp");
		ImageModel.writeImage(csui1, ".//images//15ColRCV2.bmp");
		ImageModel.writeImage(oi, ".//images//16Result.bmp");
		ImageModel.writeImage(im, ".//images//17Source.bmp");
		executed = true;
	}
	
	public static boolean isExecuted(){
		return executed;
	}
	
}
